package ru.sgu.acm.judge.misc;

import ru.sgu.acm.misc.Constants;

import java.io.IOException;
import java.util.ServiceLoader;
import java.util.Properties;

/**
 * Use this class for get constants and configuration information for Judge.
 *
 * @author Vitaly Goldshteyn (VitalyGoldstein@gmail.com)
 */
public class JudgeHelper {

    private static Properties properties = new Properties();

    /**
     * @param judgeName is name of Judge
     * @return name of login configuration file
     */
    public static String getLoginFormFileName(String judgeName) {
        return properties.getProperty("pseudocontester.judge." + judgeName + ".form.login");
    }

    /**
     * @param judgeName is name of Judge
     * @return name of submit configuration file
     */
    public static String getSubmitFormFileName(String judgeName) {
        return properties.getProperty("pseudocontester.judge." + judgeName + ".form.submit");
    }

    /**
     * @param judgeName is name of Judge
     * @return name of status configuration file
     */
    public static String getStatusFormFileName(String judgeName) {
        return properties.getProperty("pseudocontester.judge." + judgeName + ".form.status");
    }

    static {
        try {
            properties.load(JudgeHelper.class.getResourceAsStream(Constants.getJudgeMappingFileName()));
        } catch (IOException e) {
            throw new IllegalStateException("Couldn't read judge mapping properties", e);
        }
    }
}
